program->position_location = glGetAttribLocation (program->program, "position");
program->uv_location = glGetAttribLocation (program->program, "uv");
program->map_location = glGetUniformLocation (program->program, "map");
+ program->flip_location = glGetUniformLocation (program->program, "flipColors");
}
static void
gdk_gl_texture_quads (GdkGLContext *paint_context,
guint texture_target,
int n_quads,
- GdkTexturedQuad *quads)
+ GdkTexturedQuad *quads,
+ gboolean flip_colors)
{
GdkGLContextPaintData *paint_data = gdk_gl_context_get_paint_data (paint_context);
GdkGLContextProgram *program;
program = paint_data->current_program;
+ /* Use texture unit 0 */
glActiveTexture (GL_TEXTURE0);
- glUniform1i(program->map_location, 0); /* Use texture unit 0 */
+ glUniform1i(program->map_location, 0);
+
+ /* Flip 'R' and 'B' colors on GLES, if necessary */
+ if (gdk_gl_context_get_use_es (paint_context))
+ glUniform1i (program->flip_location, flip_colors ? 1 : 0);
glEnableVertexAttribArray (program->position_location);
glEnableVertexAttribArray (program->uv_location);
}
if (n_quads > 0)
- gdk_gl_texture_quads (paint_context, GL_TEXTURE_2D, n_quads, quads);
+ gdk_gl_texture_quads (paint_context, GL_TEXTURE_2D, n_quads, quads, FALSE);
g_free (quads);
/* We don't want to combine the quads here, because they have different textures.
* And we don't want to upload the unused source areas to make it one texture. */
- gdk_gl_texture_quads (paint_context, target, 1, &quad);
+ gdk_gl_texture_quads (paint_context, target, 1, &quad, TRUE);
}
}
precision mediump float;
uniform sampler2D map;
+uniform int flipColors;
varying highp vec2 vUv;
void main() {
vec4 color = texture2D(map, vUv);
- /* Flip R and B around to match the Cairo convention */
- gl_FragColor = vec4(color.z, color.y, color.x, color.w);
+ /* Flip R and B around to match the Cairo convention, if required */
+ if (flipColors == 1)
+ gl_FragColor = vec4(color.z, color.y, color.x, color.w);
+ else
+ gl_FragColor = color;
}
if (glx_pixmap == NULL)
return FALSE;
+ GDK_NOTE (OPENGL, g_message ("Using GLX_EXT_texture_from_pixmap to draw surface"));
+
window = gdk_gl_context_get_window (paint_context)->impl_window;
window_scale = gdk_window_get_scale_factor (window);
gdk_window_get_unscaled_size (window, NULL, &unscaled_window_height);
sx = sy = 1;
cairo_surface_get_device_scale (window->current_paint.surface, &sx, &sy);
-
- cairo_surface_get_device_offset (surface,
- &device_x_offset, &device_y_offset);
+ cairo_surface_get_device_offset (surface, &device_x_offset, &device_y_offset);
/* Ensure all the X stuff are synced before we read it back via texture-from-pixmap */
glXWaitX();
#undef FLIP_Y
- gdk_gl_texture_quads (paint_context, target, n_rects, quads);
+ gdk_gl_texture_quads (paint_context, target, n_rects, quads, FALSE);
g_free (quads);
glDisable (GL_SCISSOR_TEST);